<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>10-2 mouseenter和mouseleave</title>
  <style>
    .outer_box {
      width: 200px;
      height: 200px;
      border: 6px solid lightblue;
      position: relative;
    }

    .inner_box {
      width: 100px;
      height: 100px;
      border: 6px solid lightcoral;
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      right: 0;
      margin: auto;
    }
  </style>
</head>

<body>
  <div class="outer_box">outer_box
    <div class="inner_box">inner_box</div>
  </div>

  <script>
    let outer_box = document.querySelector(".outer_box");
    let inner_box = document.querySelector(".inner_box");

    // onmouseenter & onmouseleave （推荐）
    outer_box.onmouseenter = function () {
      console.log('outer_box onmouseenter');
    }
    outer_box.onmouseleave = function () {
      console.log('outer_box onmouseleave');
    }

    inner_box.onmouseenter = function () {
      console.log('inner_box onmouseenter');
    }
    inner_box.onmouseleave = function () {
      console.log('inner_box onmouseleave');
    }
  </script>
</body>

</html>